/////////////////////////////////////////////////////////////////////////////////
//
//  数组例子, 输入 1 显示penny , 输入 5 显示 nickel, 输入 10 ，显示 dime ....
//  思路: 用struct 解决
//
/////////////////////////////////////////////////////////////////////////////////
#include<iostream>

typedef struct
{
    int key;
    char *name;
} Coin;

Coin coin[]= {{1,"penny"}, {5,"nickel"}, {10,"dime"}, {25,"quarter"}, {50,"half-dollar"}};

int main()
{
    int length = sizeof(coin) / sizeof(coin[0]);
    for (int i = 0; i < length;i++)
    {
        std::cout << coin[i].key << "="<<coin[i].name<<"  ";
    }
    std::cout << std::endl;

    int key = 25;
    for (int i = 0; i < length;i++)
    {
        if(coin[i].key==key)
        {
            std::cout << coin[i].key << "="<<coin[i].name<<"  ";
            break;
        }
    }
    return EXIT_SUCCESS;
}
